package com.paradogs.framework.server;

import com.paradogs.framework.annotations.exceptionHandler.PRExceptionHandler;
import com.paradogs.framework.annotations.exceptionHandler.PRExceptionMapping;
import com.paradogs.framework.misc.GC;
import jakarta.validation.ValidationException;
import lombok.extern.slf4j.Slf4j;

/**
 * @author: yumi
 * @date: 2024/1/11  15:46
 * @Description: TODO
 */
@Slf4j
@PRExceptionHandler
public class BaseGlobalExceptionHandler {

    @PRExceptionMapping(Throwable.class)
    public GC onServiceException(Throwable e) {
        log.error("{}", e.getMessage(), e);
        return GC.fail(e.getMessage());
    }

    @PRExceptionMapping(ValidationException.class)
    public GC onValidationException(ValidationException e) {
        log.error("{}", e.getMessage());
        return GC.fail(e.getMessage());
    }

}
